"use strict";
const nodemailer = require("nodemailer");

const sendEmail=async (to,code)=> {
  let transporter = nodemailer.createTransport({
    host: "smtp.163.com",
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
      user: 'tbapman@163.com', // generated ethereal user
      pass: 'KRYZEFQCYTZDUTYI' // generated ethereal password
    }
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"【智者】" <tbapman@163.com>', // sender address
    to, // list of receivers
    subject: "智者用户注册", // Subject line
    // text: "【智者】您正在申请成为智者用户，验证码为125897，有效期5分钟", // plain text body
    html: `【智者】您正在申请成为智者用户，验证码为<b style='color:red'>${code}</b>，有效期5分钟` // html body
  })

  console.log(info,'info')
  return info
}

// sendEmail('1017571858@qq.com','123456').catch(console.error,'error');

module.exports={
  sendEmail
}